<div class="bg-light lter b-b wrapper-md">
    <h4 class="m-n font-thin">优惠券管理</h4>
    <button ui-sref="app.coupons" class="btn-back btn btn-dark btn-sm btn-rounded">
        返回
    </button>
</div>
<div class="wrapper-md" ng-controller="couponsDetailEditCtrl">
    <div class="panel panel-default">
        <div class="panel-heading m-n">
            添加优惠卷信息
        </div>
        <div class="panel-body">
            <form name="couponsForm" class="form-horizontal form-validation" ng-submit="editCoupons()">
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">优惠券名称</label>
                    <div class="col-sm-5">
                        <input type="text" name="name" ng-model="couponsDetailEditService.coupons.name" class="form-control" placeholder="请输入商品名称" required>
                    </div>
                    <div class="col-sm-5 form-text" ng-if="couponsForm.name.$touched">
                        <span class="text-danger" ng-if="couponsForm.name.$error.required">优惠券名称是必填的</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">优惠形式</label>
                    <div class="col-sm-5">
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsType" ng-model="couponsDetailEditService.coupons.type" value="0" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">指定金额</p>
                            </div>
                            <div class="inline m-b-xs" ng-if="couponsDetailEditService.coupons.type==0">
                                <p class="inline m-r-xs">面值:</p>
                                <div class="inline w-xs m-r-xs" ng-if="couponsDetailEditService.coupons.isOpenRandom==0">
                                    <input type="text" class="form-control" placeholder="固定金额" name="price" ng-model="couponsDetailEditService.coupons.price" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required disabled>
                                </div>
                                <div class="inline m-r-xs" ng-if="couponsDetailEditService.coupons.isOpenRandom==1">
                                    <input type="text" class="inline w-xs form-control m-r-xs" placeholder="开始金额" name="startPrice" ng-model="couponsDetailEditService.coupons.startPrice" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required disabled>
                                    <p class="inline m-r-xs">至</p>
                                    <input type="text" class="inline w-xs form-control m-r-xs" placeholder="结束金额" name="endPrice" ng-model="couponsDetailEditService.coupons.endPrice" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required disabled>
                                </div>
                                <div class="checkbox inline">
                                    <label class="i-checks i-checks-sm">
                                        <input type="checkbox" ng-checked="couponsDetailEditService.coupons.isOpenRandom==1" ng-click="couponsDetailEditService.coupons.isOpenRandom=couponsDetailEditService.coupons.isOpenRandom==1?0:1;" disabled><i></i>
                                        随机
                                    </label>
                                </div>
                            </div>
                            <div ng-if="couponsForm.price.$touched">
                                <p class="m-n text-danger" ng-if="couponsForm.price.$error.required">优惠金额是必填的</p>
                            </div>
                            <div ng-if="couponsForm.startPrice.$touched || couponsForm.endPrice.$touched ">
                                <p class="m-n text-danger" ng-if="couponsForm.startPrice.$error.required || couponsForm.endPrice.$error.required">优惠随机金额是必填的</p>
                            </div>
                            <div>
                                <p class="m-n text-danger" ng-if="couponsForm.price.$error.pattern || couponsForm.startPrice.$error.pattern || couponsForm.endPrice.$error.pattern">请输入正确的价格(例:99.99)</p>
                            </div>
                        </div>
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsType" ng-model="couponsDetailEditService.coupons.type" value="1" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">折扣</p>
                            </div>
                            <div class="inline" ng-if="couponsDetailEditService.coupons.type==1">
                                <p class="inline m-r-xs">折扣:</p>
                                <input type="number" min="1" max="10" step="0.01" class="inline w-xs form-control m-r-xs" name="couponsPrice" ng-model="couponsDetailEditService.coupons.discount" disabled>
                                <p class="inline m-n">折</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">数量限制</label>
                    <div class="col-sm-5">
                        <div class="m-b-sm">
                            <div class="radio inline m-r-n">
                                <label class="i-checks i-checks-sm">
                                    <input type="radio" name="couponsCount" ng-model="couponsDetailEditService.coupons.isLimitCount" value="0" disabled>
                                    <i></i>
                                </label>
                            </div>
                            <p class="font-bold inline m-n">不限制</p>
                        </div>
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsCount" ng-model="couponsDetailEditService.coupons.isLimitCount" value="1" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">数量</p>
                            </div>
                            <div class="inline" ng-if="couponsDetailEditService.coupons.isLimitCount==1">
                                <p class="inline m-r-xs">数量:</p>
                                <input type="number" min="1" max="1000" step="1" class="inline w-xs form-control m-r-xs" name="couponsLimitCount" ng-model="couponsDetailEditService.coupons.limitCount" disabled>
                                <p class="inline m-n">个</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">使用门槛</label>
                    <div class="col-sm-5">
                        <div class="m-b-xs">
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsThreshold" ng-model="couponsDetailEditService.coupons.threshold" value="0" required disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">不限制</p>
                            </div>
                        </div>
                        <div>
                            <div class="inline m-b-sm m-r-xs">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsThreshold" ng-model="couponsDetailEditService.coupons.threshold" value="1" required disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">价格满减</p>
                            </div>
                            <div class="inline" ng-if="couponsDetailEditService.coupons.threshold==1">
                                <p class="inline m-r-xs">满</p>
                                <input type="text" min="1" max="10" step="0.01" class="inline w-xs form-control m-r-xs" name="fullPriceReduction" ng-model="couponsDetailEditService.coupons.fullPriceReduction" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required disabled>
                                <p class="inline m-r-xs">元可使用</p>
                            </div>
                            <div ng-if="couponsForm.fullPriceReduction.$touched">
                                <p class="text text-danger" ng-if="couponsForm.fullPriceReduction.$error.required">满减价格是必填的</p>
                                <p class="text text-danger" ng-if="couponsForm.fullPriceReduction.$error.pattern">请填写正确的价格格式(例:99.99)</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">优惠券使用有效日期</label>
                    <div class="col-sm-10" ng-init="couponsValidTimeType=0">
                        <div class="m-b-xs">
                            <div>
                                <div class="m-b-sm">
                                    <div class="radio inline m-r-n">
                                        <label class="i-checks i-checks-sm">
                                            <input type="radio" name="couponsValidTimeType" ng-model="couponsDetailEditService.coupons.validTimeState" value="0" disabled>
                                            <i></i>
                                        </label>
                                    </div>
                                    <p class="font-bold inline m-n">固定日期</p>
                                </div>
                            </div>
                            <div class="m-b-xs" ng-if="couponsDetailEditService.coupons.validTimeState==0">
                                <div class="inline" ng-controller="DatepickerDemoCtrl">
                                    <div class="input-group w-lg">
                                        <input type="text" class="form-control" placeholder="请输入开始日期" alt-input-formats="altInputFormats" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy/MM/dd" ng-model="couponsDetailEditService.coupons.validStartTime"
                                               alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" clear-text="清空" current-text="今天" disabled/>
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-default" ng-click="open($event)" disabled><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                    </div>
                                </div>
                                <div class="inline" ng-controller="DatepickerDemoCtrl">
                                    <div class="input-group w-lg">
                                        <input type="text" class="form-control" placeholder="请输入结束日期" alt-input-formats="altInputFormats" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy/MM/dd" ng-model="couponsDetailEditService.coupons.validEndTime"
                                               alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" clear-text="清空" current-text="今天" disabled/>
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-default" ng-click="open($event)" disabled><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="m-b-sm m-r-xs">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsValidTimeType"  ng-model="couponsDetailEditService.coupons.validTimeState" value="1" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">从当天领取开始N天内有效</p>
                            </div>
                            <div ng-if="couponsDetailEditService.coupons.validTimeState==1">
                                <p class="inline m-r-xs">从当天领取开始</p>
                                <input type="number" min="1" class="inline w-xs form-control m-r-xs" name="couponsPrice" ng-model="couponsDetailEditService.coupons.validDays" disabled>
                                <p class="inline m-r-xs">天内有效</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">发放条件</label>
                    <div class="col-sm-5">
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsType" ng-model="couponsDetailEditService.coupons.grantType" value="0" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">无条件</p>
                            </div>
                        </div>
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsType" ng-model="couponsDetailEditService.coupons.grantType" value="1" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">购买满N发放</p>
                            </div>
                            <div class="inline m-b-xs" ng-if="couponsDetailEditService.coupons.grantType==1">
                                <p class="inline m-r-xs">至少消费金额:</p>
                                <div class="inline w-xs m-r-xs">
                                    <input type="text" class="form-control" placeholder="固定金额" name="price" ng-model="couponsDetailEditService.coupons.consumePrice" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" disabled>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsType" ng-model="couponsDetailEditService.coupons.grantType" value="2" disabled>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">活动领取</p>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">优惠卷下架时间</label>
                    <div class="col-sm-5">
                        <div class="inline" ng-controller="DatepickerDemoCtrl">
                            <div class="input-group w-lg">
                                <input type="text" class="form-control" datepicker-options="{showWeeks:false}" placeholder="请输入优惠卷下架时间" datepicker-options="" alt-input-formats="altInputFormats" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy/MM/dd" ng-model="couponsDetailEditService.coupons.underTime"
                                       alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" clear-text="清空" current-text="今天" disabled/>
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-default" ng-click="open($event)" disabled><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">到期提醒</label>
                    <div class="col-sm-5">
                        <div>
                            <div class="inline m-b-sm m-r-xs">
                                <div class="checkbox inline">
                                    <label class="i-checks i-checks-sm">
                                        <input type="checkbox" ng-click="couponsDetailEditService.coupons.isOpenRemind=couponsDetailEditService.coupons.isOpenRemind==1?0:1;" disabled><i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">到期前4天提醒一次</p>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">优惠券使用说明</label>
                    <div class="col-sm-5">
                        <textarea class="form-control inline" rows="5" placeholder="请输入优惠券使用说明" ng-model="couponsDetailEditService.coupons.introduce"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <button type="submit" class="btn btn-success">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>





